package com.pearadmin.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pearadmin.common.nucleus.base.BaseController;
import com.pearadmin.common.nucleus.domain.request.PageParam;
import com.pearadmin.common.nucleus.domain.response.TableVO;
import com.pearadmin.system.domain.SysOperLog;
import com.pearadmin.system.domain.SysPower;
import com.pearadmin.system.service.ISysOperLogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

@RestController
@RequestMapping("system/operLog")
public class SysOperLogController extends BaseController {

    private String MODULE_PATH = "system/operLog/";

    @Resource
    private ISysOperLogService sysOperLogService;

    @GetMapping("main")
    public ModelAndView main(ModelAndView modelAndView){
        modelAndView.setViewName(MODULE_PATH+"main");
        return modelAndView;
    }

    @GetMapping("data")
    public TableVO data(PageParam pageParam){
        QueryWrapper<SysOperLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        IPage<SysOperLog> pageInfo = sysOperLogService.page(new Page<>(pageParam.getPage(),pageParam.getLimit()),queryWrapper);
        return PageTable(pageInfo.getRecords(),pageInfo.getTotal());
    }
}
